package cdu.sl.mapper;

import cdu.sl.annotation.AutoFill;
import cdu.sl.common.enums.OperationType;
import cdu.sl.domain.po.ClassStudySet;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 班级学习集关联Mapper接口
 */
@Mapper
public interface ClassStudySetMapper extends BaseMapper<ClassStudySet> {

    @AutoFill(OperationType.INSERT)
    int insert(ClassStudySet entity);

    /**
     * 根据班级ID查询关联的学习集
     * @param classId 班级ID
     * @return 班级学习集关联列表
     */
    @Select("SELECT * FROM tb_class_study_sets WHERE class_id = #{classId} ORDER BY sort_order ASC")
    List<ClassStudySet> selectByClassId(@Param("classId") Long classId);

    /**
     * 根据学习集ID查询关联的班级
     * @param studySetId 学习集ID
     * @return 班级学习集关联列表
     */
    @Select("SELECT * FROM tb_class_study_sets WHERE study_set_id = #{studySetId}")
    List<ClassStudySet> selectByStudySetId(@Param("studySetId") Long studySetId);

} 